import time
from Case.python_ui.Common.basepage import Basepage
from Case.python_ui.PageLocate.admin_data_deletion_cre_data_locator import AdminDataDeletionCreDataLocator
from selenium.common.exceptions import NoSuchElementException, ElementClickInterceptedException
from selenium.webdriver.common.by import By

class AdminDataDeletionCreDataPage(Basepage):

    #判断是否包含元素
    def check_contain_str(self, real_result, except_string):
        if except_string.lower() in real_result.lower():
            assert True
        else:
            assert False, '实际值:' + real_result + '期望值:' + except_string

    # 校验某个属性值是否符合预期
    def check_attribute(self, real_result, except_result):
        if real_result == except_result:
            assert True
        else:
            assert False, '实际值:' + real_result + '期望值:' + except_result

    # 元素是否存在
    def element_is_exist(self, locate):
        doc = '判断元素是否存在'
        try:
            self.get_element(locate, doc)
        except NoSuchElementException as e:
            return False
        else:
            return True

    # 清空筛选状态
    def clear_filter_selection(self, filter_button_locate):
        doc = '清空筛选状态'
        try:
            #点击筛选按钮
            self.click_element(filter_button_locate[0], doc)
            time.sleep(2)
            #点击reset按钮
            self.click_element(filter_button_locate[1], doc)
        except ElementClickInterceptedException as e:
            self.click_element(filter_button_locate[2], doc)
            return
        else:
            self.click_element(filter_button_locate[2], doc)
            return

    # 列表筛选功能
    def check_filter_search_result(self, search_num_locate, column_num, filter_button_locate, filter_selection_locate, filter_value):
        doc = '校验筛选结果'
        # 定义一个数组，当筛选项是没有查询结果时，存False
        result_arry = []
        # 定义一个i, 用来取filter_value 的值
        i = 0
        for selection in filter_selection_locate:
            # 清空筛选条件
            self.clear_filter_selection(filter_button_locate)
            time.sleep(2)
            self.click_element(filter_button_locate[0], doc)
            time.sleep(2)
            self.click_element(selection, doc)
            time.sleep(2)
            self.click_element(filter_button_locate[2], doc)
            time.sleep(5)
            if self.element_is_exist(search_num_locate) is False:
                result_arry.append(False)
                i = i + 1
                continue
            search_result = self.get_element(search_num_locate, doc).text
            search_num = int(search_result.split(' ', 2)[1])
            if search_num <= 10:
                for j in range(1, search_num + 1):
                    real_result = self.get_element(self.assemble_list_element_locate(str(j), str(column_num)), doc).text
                    self.check_attribute(real_result, filter_value[i])
            if search_num > 10:
                for j in range(1, 11):
                    real_result = self.get_element(self.assemble_list_element_locate(str(j), str(column_num)), doc).text
                    self.check_attribute(real_result, filter_value[i])
            result_arry.append(True)
            i = i + 1
        # 最后清空筛选条件
        self.clear_filter_selection(filter_button_locate)
        return result_arry


    def assemble_list_element_locate(self, row, column):
        list_locate = '(//tr[contains(@class,"antd4-table-row antd4-table-row-level-0")])[$_1]//td[$_2]'
        search_result = (By.XPATH, list_locate.replace('$_1', row).replace('$_2', column))
        return search_result

    def assemble_filter_selection_locate(self, num):
        list_locate = '(//input[contains(@class,"antd4-checkbox-input")])[$_1]'
        status_selection_locate = (By.XPATH, list_locate.replace('$_1', num))
        return status_selection_locate

    # 校验模糊查询结果
    def fuzzy_check_search_result(self, search_num_locate, column_num, expect_result):
        doc = '检查模糊查询结果'
        if self.element_is_exist(search_num_locate) is False:
            return False
        search_result = self.get_element(search_num_locate, doc).text
        search_num = int(search_result.split(' ', 2)[1])
        if search_num <= 10:
            for j in range(1, search_num + 1):
                real_result = self.get_element(self.assemble_list_element_locate(str(j), str(column_num)), doc).text
                self.check_contain_str(real_result, expect_result)
        if search_num > 10:
            for j in range(1, 11):
                real_result = self.get_element(self.assemble_list_element_locate(str(j), str(column_num)), doc).text
                self.check_contain_str(real_result, expect_result)

    # 校验查询结果
    def check_search_result(self, search_num_locate, column_num, expect_result):
        doc = '检查查询结果'
        if self.element_is_exist(search_num_locate) is False:
            return False
        search_result = self.get_element(search_num_locate, doc).text
        search_num = int(search_result.split(' ', 2)[1])
        if search_num <= 10:
            for j in range(1, search_num + 1):
                real_result = self.get_element(self.assemble_list_element_locate(str(j), str(column_num)), doc).text
                self.check_attribute(real_result, expect_result)
        if search_num > 10:
            for j in range(1, 11):
                real_result = self.get_element(self.assemble_list_element_locate(str(j), str(column_num)), doc).text
                self.check_attribute(real_result, expect_result)

    def check_fuzzy_search_result(self, fuzzy_criteria, search_input_locate, search_button_locate, search_result_num_locate, column_num):
        doc = '模糊搜索'
        for value in fuzzy_criteria:
            self.keyboard_event(search_input_locate, doc)
            self.send_keys(search_input_locate, value, doc)
            time.sleep(2)
            self.click_element(search_button_locate, doc)
            time.sleep(5)
            #校验查询结果
            self.fuzzy_check_search_result(search_result_num_locate, column_num, value)

    def check_full_search_result(self, full_criteria, search_input_locate, search_button_locate, search_result_num_locate, column_num):
        doc = '全匹配搜索'
        for value in full_criteria:
            self.keyboard_event(search_input_locate, doc)
            self.send_keys(search_input_locate, value, doc)
            time.sleep(2)
            self.click_element(search_button_locate, doc)
            time.sleep(5)
            # 校验查询结果
            self.check_search_result(search_result_num_locate, column_num, value)

    #进入CRE Data 菜单页面
    def enter_cre_data_page(self):
        time.sleep(2)
        doc = "进入CRE Data 菜单页面"
        js_object = 'document.getElementsByClassName("cre-sider-menu cre-sider-menu-open")[0].scrollTop=10000'
        self.excute_js(js_object)
        # self.wait_elevisble(AdminDataDeletionCreDataLocator.data_deletion_menu, doc)
        # self.click_element(AdminDataDeletionCreDataLocator.data_deletion_menu, doc)
        time.sleep(2)
        self.wait_elevisble(AdminDataDeletionCreDataLocator.cre_data_menu, doc)
        self.click_element(AdminDataDeletionCreDataLocator.cre_data_menu, doc)
        time.sleep(3)

    # 检查列表属性字段
    def check_cre_data_list_attribute(self):
        time.sleep(2)
        self.check_list_attribute()

    # 检查页面说明
    def check_hit_content(self):
        doc = '检查页面的说明内容'
        time.sleep(2)
        #检查下载的提示语
        self.wait_elevisble(AdminDataDeletionCreDataLocator.download_hit_content, doc)
        #检查问号的提示语
        self.move_mouse_to_click_element(AdminDataDeletionCreDataLocator.question_hit, doc)
        time.sleep(2)
        self.wait_elevisble(AdminDataDeletionCreDataLocator.question_hit_content, doc)

    #检查搜索选项
    def check_search_type(self):
        doc = '检查搜索选项'
        search_type = ['Account Email', 'User Name', 'Importer']
        time.sleep(2)
        self.check_attribute(self.get_element(AdminDataDeletionCreDataLocator.search_type, doc).text, search_type[0])
        self.click_element(AdminDataDeletionCreDataLocator.search_type, doc)
        time.sleep(2)
        self.check_attribute(self.get_element(AdminDataDeletionCreDataLocator.search_type_user_name, doc).text, search_type[1])
        self.check_attribute(self.get_element(AdminDataDeletionCreDataLocator.search_type_importer, doc).text, search_type[2])

    def search_cre_data(self):
        doc = '检查搜索结果'
        #account email 查询
        account_email_fuzzy_criteria = ['test', '32']
        account_email_full_criteria = ['test4321@qq.com']
        self.check_fuzzy_search_result(account_email_fuzzy_criteria, AdminDataDeletionCreDataLocator.search_input, AdminDataDeletionCreDataLocator.search_button, AdminDataDeletionCreDataLocator.search_result_num, 2)
        self.check_full_search_result(account_email_full_criteria, AdminDataDeletionCreDataLocator.search_input, AdminDataDeletionCreDataLocator.search_button, AdminDataDeletionCreDataLocator.search_result_num, 2)
        # user name查询
        self.click_element(AdminDataDeletionCreDataLocator.search_type, doc)
        time.sleep(2)
        self.click_element(AdminDataDeletionCreDataLocator.search_type_user_name, doc)
        time.sleep(2)
        user_name_fuzzy_criteria = ['test', '32']
        user_name_full_criteria = ['ldhtest32']
        self.check_fuzzy_search_result(user_name_fuzzy_criteria, AdminDataDeletionCreDataLocator.search_input, AdminDataDeletionCreDataLocator.search_button, AdminDataDeletionCreDataLocator.search_result_num, 9)
        self.check_full_search_result(user_name_full_criteria, AdminDataDeletionCreDataLocator.search_input, AdminDataDeletionCreDataLocator.search_button, AdminDataDeletionCreDataLocator.search_result_num, 9)
        # importer查询
        self.click_element(AdminDataDeletionCreDataLocator.search_type, doc)
        time.sleep(2)
        self.click_element(AdminDataDeletionCreDataLocator.search_type_importer, doc)
        time.sleep(2)
        importer_fuzzy_criteria = ['lwm', '5286750']
        importer_full_criteria = ['lwm528675013@163.com']
        self.check_fuzzy_search_result(importer_fuzzy_criteria, AdminDataDeletionCreDataLocator.search_input, AdminDataDeletionCreDataLocator.search_button, AdminDataDeletionCreDataLocator.search_result_num, 10)
        self.check_full_search_result(importer_full_criteria, AdminDataDeletionCreDataLocator.search_input, AdminDataDeletionCreDataLocator.search_button, AdminDataDeletionCreDataLocator.search_result_num, 10)
        # 点击reset按钮
        doc = '点击reset按钮'
        self.click_element(AdminDataDeletionCreDataLocator.reset_button, doc)
        time.sleep(3)
        assert self.get_element(AdminDataDeletionCreDataLocator.search_input, doc).text == '', '搜索框不为空' + self.get_element(AdminDataDeletionCreDataLocator.search_input, doc).text

    # 筛选查询
    def filter_cre_data(self):
        doc = '筛选查询'
        # 状态筛选
        status_filter_value = ['Undeleted', 'Deleting', 'Abnormal', 'Deleted']
        status_filter_selection_locate = [AdminDataDeletionCreDataLocator.status_filter_undeleted_button, AdminDataDeletionCreDataLocator.status_filter_deleting_button, AdminDataDeletionCreDataLocator.status_filter_abnormal_button, AdminDataDeletionCreDataLocator.status_filter_deleted_button]
        status_filter_button_locate = [AdminDataDeletionCreDataLocator.status_filter_button, AdminDataDeletionCreDataLocator.status_filter_reset_button, AdminDataDeletionCreDataLocator.status_filter_ok_button]
        self.check_filter_search_result(AdminDataDeletionCreDataLocator.search_result_num, 3, status_filter_button_locate, status_filter_selection_locate, status_filter_value)
        # 支付模式筛选
        pm_filter_value = ['PrePaid', 'PostPaid']
        pm_filter_selection_locate = [AdminDataDeletionCreDataLocator.pm_filter_pre_button, AdminDataDeletionCreDataLocator.pm_filter_post_button]
        pm_filter_button_locate = [AdminDataDeletionCreDataLocator.pm_filter_button, AdminDataDeletionCreDataLocator.pm_filter_reset_button, AdminDataDeletionCreDataLocator.pm_filter_ok_button]
        self.check_filter_search_result(AdminDataDeletionCreDataLocator.search_result_num, 5, pm_filter_button_locate, pm_filter_selection_locate, pm_filter_value)
        # 账号类型筛选
        account_filter_value = ['Enterprise', 'Personal']
        account_filter_selection_locate = [AdminDataDeletionCreDataLocator.account_filter_pre_button, AdminDataDeletionCreDataLocator.account_filter_post_button]
        account_filter_button_locate = [AdminDataDeletionCreDataLocator.account_filter_button, AdminDataDeletionCreDataLocator.account_filter_reset_button, AdminDataDeletionCreDataLocator.account_filter_ok_button]
        self.check_filter_search_result(AdminDataDeletionCreDataLocator.search_result_num, 8, account_filter_button_locate, account_filter_selection_locate, account_filter_value)

    # 检查log 页面
    def check_log_details_page(self):
        doc = '检查log 页面'
        account_email = 'test4321@qq.com'
        self.send_keys(AdminDataDeletionCreDataLocator.search_input, account_email, doc)
        time.sleep(2)
        self.click_element(AdminDataDeletionCreDataLocator.search_button, doc)
        time.sleep(5)
        #点击log按钮
        self.click_element(AdminDataDeletionCreDataLocator.log_button, doc)
        time.sleep(3)
        doc = '校验详情页面属性'
        self.get_element(AdminDataDeletionCreDataLocator.log_detail_title_oi, doc)
        self.get_element(AdminDataDeletionCreDataLocator.log_detail_title_bi, doc)
        self.get_element(AdminDataDeletionCreDataLocator.log_detail_title_ddd, doc)

    # 检查log details页面 basic information
    def check_log_details_bi(self):
        doc = '检查log details页面 basic information'
        # 搜索记录
        account_email = 'test4321@qq.com'
        self.send_keys(AdminDataDeletionCreDataLocator.search_input, account_email, doc)
        time.sleep(2)
        self.click_element(AdminDataDeletionCreDataLocator.search_button, doc)
        time.sleep(5)
        #获取查询结果
        search_result = []
        search_result.append(self.get_element(AdminDataDeletionCreDataLocator.first_search_result_account_email, doc).text)
        search_result.append(self.get_element(AdminDataDeletionCreDataLocator.first_search_result_status, doc).text)
        search_result.append(self.get_element(AdminDataDeletionCreDataLocator.first_search_result_create_time, doc).text)
        search_result.append(self.get_element(AdminDataDeletionCreDataLocator.first_search_result_payment_mode, doc).text)
        search_result.append(self.get_element(AdminDataDeletionCreDataLocator.first_search_result_available_balance, doc).text)
        search_result.append(self.get_element(AdminDataDeletionCreDataLocator.first_search_result_outstanding_amount, doc).text)
        search_result.append(self.get_element(AdminDataDeletionCreDataLocator.first_search_result_account_type, doc).text)
        search_result.append(self.get_element(AdminDataDeletionCreDataLocator.first_search_result_user_name, doc).text)
        search_result.append(self.get_element(AdminDataDeletionCreDataLocator.first_search_result_importer, doc).text)
        search_result.append(self.get_element(AdminDataDeletionCreDataLocator.first_search_result_import_time, doc).text)
        #点击log按钮
        self.click_element(AdminDataDeletionCreDataLocator.log_button, doc)
        time.sleep(3)
        # 详情信息
        detail_result = []
        detail_result.append(self.get_element(AdminDataDeletionCreDataLocator.log_detail_account_email, doc).text)
        detail_result.append(self.get_element(AdminDataDeletionCreDataLocator.log_detail_status, doc).text)
        detail_result.append(self.get_element(AdminDataDeletionCreDataLocator.log_detail_creation_time, doc).text)
        detail_result.append(self.get_element(AdminDataDeletionCreDataLocator.log_detail_payment_mode, doc).text)
        detail_result.append(self.get_element(AdminDataDeletionCreDataLocator.log_detail_available_balance, doc).text)
        detail_result.append(self.get_element(AdminDataDeletionCreDataLocator.log_detail_oustanding_amount, doc).text)
        detail_result.append(self.get_element(AdminDataDeletionCreDataLocator.log_detail_account_type, doc).text)
        detail_result.append(self.get_element(AdminDataDeletionCreDataLocator.log_detail_user_name, doc).text)
        detail_result.append(self.get_element(AdminDataDeletionCreDataLocator.log_detail_importer, doc).text)
        detail_result.append(self.get_element(AdminDataDeletionCreDataLocator.log_detail_importer_time, doc).text)
        # 比较详情列表
        self.check_attribute(self.get_element(AdminDataDeletionCreDataLocator.first_search_result_account_email, doc).text, self.get_element(AdminDataDeletionCreDataLocator.log_detail_account_email, doc).text)
        self.check_attribute(self.get_element(AdminDataDeletionCreDataLocator.first_search_result_status, doc).text, self.get_element(AdminDataDeletionCreDataLocator.log_detail_status, doc).text)
        self.check_attribute(self.get_element(AdminDataDeletionCreDataLocator.first_search_result_create_time, doc).text, self.get_element(AdminDataDeletionCreDataLocator.log_detail_creation_time, doc).text)
        self.check_attribute(self.get_element(AdminDataDeletionCreDataLocator.first_search_result_payment_mode, doc).text, self.get_element(AdminDataDeletionCreDataLocator.log_detail_payment_mode, doc).text)
        if self.get_element(AdminDataDeletionCreDataLocator.first_search_result_available_balance, doc).text == '-':
            assert self.get_element(AdminDataDeletionCreDataLocator.log_detail_available_balance, doc).text == '0.00'
        else:
            self.check_contain_str(self.get_element(AdminDataDeletionCreDataLocator.first_search_result_available_balance, doc).text, self.get_element(AdminDataDeletionCreDataLocator.log_detail_available_balance, doc).text)
        if self.get_element(AdminDataDeletionCreDataLocator.first_search_result_outstanding_amount, doc).text == '-':
            assert self.get_element(AdminDataDeletionCreDataLocator.log_detail_oustanding_amount, doc).text == '0.00'
        else:
            self.check_contain_str(self.get_element(AdminDataDeletionCreDataLocator.first_search_result_outstanding_amount, doc).text, self.get_element(AdminDataDeletionCreDataLocator.log_detail_oustanding_amount, doc).text)
        self.check_attribute(self.get_element(AdminDataDeletionCreDataLocator.first_search_result_account_type, doc).text, self.get_element(AdminDataDeletionCreDataLocator.log_detail_account_type, doc).text)
        self.check_attribute(self.get_element(AdminDataDeletionCreDataLocator.first_search_result_user_name, doc).text, self.get_element(AdminDataDeletionCreDataLocator.log_detail_user_name, doc).text)
        self.check_attribute(self.get_element(AdminDataDeletionCreDataLocator.first_search_result_importer, doc).text, self.get_element(AdminDataDeletionCreDataLocator.log_detail_importer, doc).text)
        self.check_attribute(self.get_element(AdminDataDeletionCreDataLocator.first_search_result_import_time, doc).text, self.get_element(AdminDataDeletionCreDataLocator.log_detail_importer_time, doc).text)

    # 检查log details页面 operation information
    def check_log_details_oi(self):
        doc = '检查log details页面 operation information'
        # 搜索记录
        account_email = 'test4321@qq.com'
        self.send_keys(AdminDataDeletionCreDataLocator.search_input, account_email, doc)
        time.sleep(2)
        self.click_element(AdminDataDeletionCreDataLocator.search_button, doc)
        time.sleep(5)
        #点击log按钮
        self.click_element(AdminDataDeletionCreDataLocator.log_button, doc)
        time.sleep(3)
        #校验列表属性
        attribute_list = ['Operation ID', 'Operator', 'Operator IP', 'Operation Time', 'Operation Result']
        list_attribute_0 = self.get_element(AdminDataDeletionCreDataLocator.log_detail_oi_operation_id, doc).text
        self.check_contain_str(list_attribute_0, attribute_list[0])
        list_attribute_1 = self.get_element(AdminDataDeletionCreDataLocator.log_detail_oi_operator, doc).text
        self.check_contain_str(list_attribute_1, attribute_list[1])
        list_attribute_2 = self.get_element(AdminDataDeletionCreDataLocator.log_detail_oi_operator_ip, doc).text
        self.check_contain_str(list_attribute_2, attribute_list[2])
        list_attribute_3 = self.get_element(AdminDataDeletionCreDataLocator.log_detail_oi_operation_time, doc).text
        self.check_contain_str(list_attribute_3, attribute_list[3])
        list_attribute_4 = self.get_element(AdminDataDeletionCreDataLocator.log_detail_oi_operation_result, doc).text
        self.check_contain_str(list_attribute_4, attribute_list[4])
        #判断列表是否是按operation id 倒叙
        doc = '判断列表是否是按operation id 倒叙'
        search_num = int(self.get_element(AdminDataDeletionCreDataLocator.log_detail_oi_operation_num, doc).text.split(' ', 2)[1])
        operation_id = []
        if search_num <= 10:
            for j in range(1, search_num + 1):
                locate = "//div[contains(@class,'antd4-table antd4-table-scroll-horizontal')]//tr[$_1]/td[1]/div".replace('$_1', str(j+1))
                log_detail_oi_operation_id = (By.XPATH, locate)
                id = self.get_element(log_detail_oi_operation_id, doc).text
                operation_id.append(id)
            #先将list正序，再倒叙，然后判断原始的list和倒叙的是否一致
            assert operation_id == list(reversed(sorted(operation_id))), "operation id 不是倒叙"
        if search_num > 10:
            for j in range(1, 11):
                locate = "//div[contains(@class,'antd4-table antd4-table-scroll-horizontal')]//tr[$_1]/td[1]/div".replace('$_1', str(j + 1))
                log_detail_oi_operation_id = (By.XPATH, locate)
                id = self.get_element(log_detail_oi_operation_id, doc).text
                operation_id.append(id)
                # 先将list正序，再倒叙，然后判断原始的list和倒叙的是否一致
            assert operation_id == list(reversed(sorted(operation_id))), "operation id 不是倒叙"

    # 检查log details页面 data deleting detail
    def check_log_details_ddd(self):
        doc = '检查log details页面data deleting detail'
        # 搜索记录
        account_email = 'test4321@qq.com'
        self.send_keys(AdminDataDeletionCreDataLocator.search_input, account_email, doc)
        time.sleep(2)
        self.click_element(AdminDataDeletionCreDataLocator.search_button, doc)
        time.sleep(5)
        #点击log按钮
        self.click_element(AdminDataDeletionCreDataLocator.log_button, doc)
        time.sleep(3)
        #校验列表属性
        attribute_list = ['Operation ID', 'Data Type', 'Value', 'Status', 'Start Time', 'End Time']
        list_attribute_0 = self.get_element(AdminDataDeletionCreDataLocator.log_detail_ddd_operation_id, doc).text
        self.check_contain_str(list_attribute_0, attribute_list[0])
        list_attribute_1 = self.get_element(AdminDataDeletionCreDataLocator.log_detail_ddd_data_type, doc).text
        self.check_contain_str(list_attribute_1, attribute_list[1])
        list_attribute_2 = self.get_element(AdminDataDeletionCreDataLocator.log_detail_ddd_value, doc).text
        self.check_contain_str(list_attribute_2, attribute_list[2])
        list_attribute_3 = self.get_element(AdminDataDeletionCreDataLocator.log_detail_ddd_status, doc).text
        self.check_contain_str(list_attribute_3, attribute_list[3])
        list_attribute_4 = self.get_element(AdminDataDeletionCreDataLocator.log_detail_ddd_start_time, doc).text
        self.check_contain_str(list_attribute_4, attribute_list[4])
        list_attribute_5 = self.get_element(AdminDataDeletionCreDataLocator.log_detail_ddd_end_time, doc).text
        self.check_contain_str(list_attribute_5, attribute_list[5])
        # 判断列表是否是按operation id 倒叙
        doc = '判断列表是否是按operation id 倒叙'
        search_num = int(self.get_element(AdminDataDeletionCreDataLocator.log_detail_ddd_operation_num, doc).text.split(' ', 2)[1])
        operation_id = []
        if search_num <= 10:
            for j in range(1, search_num + 1):
                locate = "//div[contains(@class,'antd4-table antd4-table-ping-right antd4-table-scroll-horizontal')]//tr[$_1]/td[1]/div".replace(
                    '$_1', str(j + 1))
                log_detail_oi_operation_id = (By.XPATH, locate)
                id = self.get_element(log_detail_oi_operation_id, doc).text
                operation_id.append(id)
            # 先将list正序，再倒叙，然后判断原始的list和倒叙的是否一致
            assert operation_id == list(reversed(sorted(operation_id))), "operation id 不是倒叙"
        if search_num > 10:
            for j in range(1, 11):
                locate = "//div[contains(@class,'antd4-table antd4-table-ping-right antd4-table-scroll-horizontal')]//tr[$_1]/td[1]/div".replace('$_1', str(j + 1))
                log_detail_oi_operation_id = (By.XPATH, locate)
                id = self.get_element(log_detail_oi_operation_id, doc).text
                operation_id.append(id)
                # 先将list正序，再倒叙，然后判断原始的list和倒叙的是否一致
            assert operation_id == list(reversed(sorted(operation_id))), "operation id 不是倒叙"

    def check_cre_ascm_permission(self):
        time.sleep(2)
        doc = "进入CRE Data 菜单页面"
        js_object = 'document.getElementsByClassName("cre-sider-menu cre-sider-menu-open")[0].scrollTop=10000'
        self.excute_js(js_object)
        time.sleep(2)
        assert not self.element_is_exist(AdminDataDeletionCreDataLocator.cre_ascm_data_menu), '能够找到元素'
        time.sleep(2)
        #通过url访问
        url = 'https://testcreadmin.aligy.cn/console/creData'
        self.driver.get(url)
        time.sleep(5)
        assert self.element_is_exist(AdminDataDeletionCreDataLocator.no_permission), '不能找到元素'


    # 校验列表元素
    #时区，货币单位需要单独提出来，根据配置文件来校验  --待优化
    def check_list_attribute(self):
        time.sleep(2)
        doc = "校验列表元素"
        attribute_list = ['Account Email', 'Status', 'Creation Time', 'Payment Mode', 'Available Balance', 'Outstanding Amount', 'Account Type', 'User Name', 'Importer', 'Import Time']
        list_attribute_0 = self.get_element(AdminDataDeletionCreDataLocator.record_list_account_email, doc).text
        self.check_contain_str(list_attribute_0, attribute_list[0])
        list_attribute_1 = self.get_element(AdminDataDeletionCreDataLocator.record_list_status, doc).text
        self.check_contain_str(list_attribute_1, attribute_list[1])
        list_attribute_2 = self.get_element(AdminDataDeletionCreDataLocator.record_list_create_time, doc).text
        self.check_contain_str(list_attribute_2, attribute_list[2])
        list_attribute_3 = self.get_element(AdminDataDeletionCreDataLocator.record_list_payment_mode, doc).text
        self.check_contain_str(list_attribute_3, attribute_list[3])
        list_attribute_4 = self.get_element(AdminDataDeletionCreDataLocator.record_list_available_balance, doc).text
        self.check_contain_str(list_attribute_4, attribute_list[4])
        list_attribute_5 = self.get_element(AdminDataDeletionCreDataLocator.record_list_outstanding_amount, doc).text
        self.check_contain_str(list_attribute_5, attribute_list[5])
        list_attribute_6 = self.get_element(AdminDataDeletionCreDataLocator.record_list_account_type, doc).text
        self.check_contain_str(list_attribute_6, attribute_list[6])
        list_attribute_7 = self.get_element(AdminDataDeletionCreDataLocator.record_list_user_name, doc).text
        self.check_contain_str(list_attribute_7, attribute_list[7])
        list_attribute_8 = self.get_element(AdminDataDeletionCreDataLocator.record_list_importer, doc).text
        self.check_contain_str(list_attribute_8, attribute_list[8])
        list_attribute_9 = self.get_element(AdminDataDeletionCreDataLocator.record_list_import_time, doc).text
        self.check_contain_str(list_attribute_9, attribute_list[9])
        time.sleep(3)

